// pages/course/course.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    carouselChart:[],
    courseList:[]

  },
  enterCourseIn(event){
    const title = event.currentTarget.dataset.title;
    const courseId = event.currentTarget.dataset.id
    console.log(title)
    console.log(courseId)
    wx.navigateTo({
      url: `../course_detail/course_in/course_in?title=${title}&courseId=${courseId}`,
    })
  },
  goSearch(){
    wx.navigateTo({
      url: '../course_detail/course_find/course_find',
    })
  },
  enterConsult(){
    wx.navigateTo({
      url: '../course_detail/course_team/course_team',
    })
  },
  enterConsultAnnouncement(){
      wx.navigateTo({
        url: '../consultant_announcement/consultant_announcement',
      })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getCarouselChart();
    this.getCourseList();

  },
  enterCourseOnline(){
    wx.navigateTo({
      url: '../course_detail/course_online/course_online',
    })

  },
  getCarouselChart() {
    wx.request({
      url: 'http://localhost:8085/course?pageNum=1&pageSize=10',
      method: "GET",
      success: (res) => {
        console.log(res.data)
        if (res.data.code === 200) {
          this.setData({
            carouselChart: res.data.data.list.slice(0, 4),
          });
        }
      },
    });
  },
  getCourseList(){
    wx.request({
      url: 'http://localhost:8085/course?pageNum=1&pageSize=10',
      method: "GET",
      success: (res) => {
        if (res.data.code === 200) {
          this.setData({
            courseList: res.data.data.list.slice(4, 10),
          });
        }
      },
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})